<?php

namespace app\models\user\gr;

use Yii;

/**
 * This is the model class for table "{{%users_baseinfo_gr}}".
 *
 * @property int $id 用户id和users表id对应
 * @property int|null $isbase 是否填写基本信息
 * @property int|null $iszhengjian 是否填写证件信息
 * @property int|null $isjiaoyubeijing 教育背景
 * @property int|null $isgongzuojingli 工作经历
 * @property int|null $isjiatingchengyuan 家庭成员
 * @property int|null $isqiuzhiyixiang 求职意向
 * @property int|null $time 创建时间
 * @property int|null $isziwopingjia 自我评价
 * @property int|null $qiuzhiyixiangType 求职意向类型,'gs'表示公司员工，'gc'表示工厂员工
 */
class UsersBaseinfoGr extends \app\models\BaseUserModel
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%users_baseinfo_gr}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['isbase', 'iszhengjian', 'isjiaoyubeijing', 'isgongzuojingli', 'isjiatingchengyuan',
                'isqiuzhiyixiang', 'time', 'isziwopingjia','qiuzhiyixiangType'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'isbase' => '是否填写基本信息',
            'iszhengjian' => '是否填写证件信息',
            'isjiaoyubeijing' => '教育背景',
            'isgongzuojingli' => '工作经历',
            'isjiatingchengyuan' => '家庭成员',
            'isqiuzhiyixiang' => '求职意向',
            'time' => 'Time',
            'isziwopingjia' => '自我评价',
            'qiuzhiyixiangType' => '求职意向类型',
            'isqiuzhiyixiang2'=>'求职意向2'
        ];
    }

    public static function setIS($Field,$val=1, $uid=null)
    {
        if($uid===null){
            $uid=Yii::$app->user->getId();
        }
        $one = self::find()->where([
            'id' => $uid
        ])->one();
        if (!$one) {
            $one = new self;
            $one->id = $uid;
        }
        $one[$Field] = $val;
        $one->save();
    }

    /**
     * 求职类型转化为字符串类型
    */
    public function toqiuzhiyixiangTypeIntStr($type){
        if($type==self::qiuzhiyixiangType_GS){
            return 'qiuzhiyixiangType_GS';
        }elseif($type==self::qiuzhiyixiangType_GC){
            return 'qiuzhiyixiangType_GC';
        }
        return $type;
    }
    public function __get($name)
    {
        if($name=='isqiuzhiyixiang2'){
            return $this->isqiuzhiyixiang;
        }
        return parent::__get($name); // TODO: Change the autogenerated stub
    }

}
